package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysProjectPayer;
import com.ruoyi.system.service.ISysProjectPayerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务费付款方Controller
 *
 * @author ruoyi
 * @date 2024-08-03
 */
@RestController
@RequestMapping("/system/projectpayer")
public class SysProjectPayerController extends BaseController
{
    @Autowired
    private ISysProjectPayerService sysProjectPayerService;

    /**
     * 查询服务费付款方列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectpayer:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysProjectPayer sysProjectPayer)
    {
        startPage();
        List<SysProjectPayer> list = sysProjectPayerService.selectSysProjectPayerList(sysProjectPayer);
        return getDataTable(list);
    }

    /**
     * 查询服务费付款方列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectpayer:lists')")
    @GetMapping("/lists")
    public AjaxResult lists(SysProjectPayer sysProjectPayer)
    {
        List<SysProjectPayer> list = sysProjectPayerService.selectSysProjectPayerList(sysProjectPayer);
        return success(list);
    }

    /**
     * 导出服务费付款方列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectpayer:export')")
    @Log(title = "服务费付款方", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysProjectPayer sysProjectPayer)
    {
        List<SysProjectPayer> list = sysProjectPayerService.selectSysProjectPayerList(sysProjectPayer);
        ExcelUtil<SysProjectPayer> util = new ExcelUtil<SysProjectPayer>(SysProjectPayer.class);
        util.exportExcel(response, list, "服务费付款方数据");
    }

    /**
     * 获取服务费付款方详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:projectpayer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysProjectPayerService.selectSysProjectPayerById(id));
    }

    /**
     * 新增服务费付款方
     */
    @PreAuthorize("@ss.hasPermi('system:projectpayer:add')")
    @Log(title = "服务费付款方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysProjectPayer sysProjectPayer)
    {
        return toAjax(sysProjectPayerService.insertSysProjectPayer(sysProjectPayer));
    }

    /**
     * 修改服务费付款方
     */
    @PreAuthorize("@ss.hasPermi('system:projectpayer:edit')")
    @Log(title = "服务费付款方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysProjectPayer sysProjectPayer)
    {
        return toAjax(sysProjectPayerService.updateSysProjectPayer(sysProjectPayer));
    }

    /**
     * 删除服务费付款方
     */
    @PreAuthorize("@ss.hasPermi('system:projectpayer:remove')")
    @Log(title = "服务费付款方", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysProjectPayerService.deleteSysProjectPayerByIds(ids));
    }
}
